/**
 * Filename: YNUrlHelper.java
 *
 * @author Firefly
 * @contact postfirefly@163.com
 * @time 2016/5/15 14:30
 */
package com.github.postsanf.yinian.utils;

import android.content.Context;
import android.os.Build;

import com.github.postsanf.yinian.R;
import com.liulishuo.qiniuimageloader.QiniuImageLoader;

public class YNUrlHelper {

    public static boolean isKitkatUp() {
        return Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
    }

    public static String getHomeImgUrl(Context mContext, String url) {
        return isKitkatUp() ? new QiniuImageLoader(mContext, url).formatWebp().wR(R.dimen.hw_home_full_width).createQiniuUrl() : new QiniuImageLoader(mContext, url).formatJpg().wR(R.dimen.hw_home_full_width).createQiniuUrl();
    }

    public static String getStatusBlur(Context mContext, String url) {
        return isKitkatUp() ? new QiniuImageLoader(mContext, url).formatWebp().screenW().addOpBlur(20, 10).createQiniuUrl() : new QiniuImageLoader(mContext, url).formatJpg().screenW().addOpBlur(20, 10).createQiniuUrl();
    }


    public static String getStatusUrl(Context mContext, String url) {
        if (SystemUtils.isRedmi()) {
            return new QiniuImageLoader(mContext, url).sizeR(R.dimen.hw_status_mi).formatJpg().centerCrop().createQiniuUrl();
        } else {
            return isKitkatUp() ? new QiniuImageLoader(mContext, url).sizeR(R.dimen.hw_status_size).centerCrop().formatWebp().createQiniuUrl() : new QiniuImageLoader(mContext, url).sizeR(R.dimen.hw_status_size).formatJpg().centerCrop().createQiniuUrl();
        }
    }

    public static String getSharePhotoUrl(Context mContext, String url) {
        return new QiniuImageLoader(mContext, url).halfScreenW().formatWebp().centerCrop().createQiniuUrl();
    }

    public static String getWallUrl(Context mContext, String url) {
        return isKitkatUp() ? new QiniuImageLoader(mContext, url).sizeR(R.dimen.hw_browse_full_width).centerCrop().formatWebp().createQiniuUrl() : new QiniuImageLoader(mContext, url).sizeR(R.dimen.hw_browse_full_width).formatJpg().centerCrop().createQiniuUrl();
    }

    public static String getBrowseBlur(Context mContext, String url) {
        return isKitkatUp() ? new QiniuImageLoader(mContext, url).formatWebp().centerCrop().wR(R.dimen.hw_browse_full_width).hR(R.dimen.hw_timeline_size).addOpBlur(20, 10).createQiniuUrl() : new QiniuImageLoader(mContext, url).formatJpg().centerCrop().wR(R.dimen.hw_browse_full_width).hR(R.dimen.hw_timeline_size).addOpBlur(20, 10).createQiniuUrl();
    }

    public static String getOfficialUrl(Context mContext, String url) {
        return isKitkatUp() ? new QiniuImageLoader(mContext, url).formatWebp().wR(R.dimen.hw_official_album_width).createQiniuUrl() : new QiniuImageLoader(mContext, url).formatJpg().wR(R.dimen.hw_official_album_width).createQiniuUrl();
    }

    public static String getTimeLineUrl(Context mContext, String url) {
        return isKitkatUp() ? new QiniuImageLoader(mContext, url).formatWebp().wR(R.dimen.hw_timeline_size).createQiniuUrl() : new QiniuImageLoader(mContext, url).formatJpg().wR(R.dimen.hw_timeline_size).createQiniuUrl();
    }

    public static String getTimeCircleUrl(Context mContext, String url) {
        return isKitkatUp() ? new QiniuImageLoader(mContext, url).formatWebp().sizeR(R.dimen.hw_browse_full_width).createQiniuUrl() : new QiniuImageLoader(mContext, url).formatJpg().sizeR(R.dimen.hw_browse_full_width).createQiniuUrl();
    }

    public static String getAvatarUrl(Context mContext, String url) {
        return new QiniuImageLoader(mContext, url).sizeR(R.dimen.hw_avatar_size).centerCrop().formatJpg().createQiniuUrl();
    }

    public static String getTodayUrl(Context mContext, String url) {
        return new QiniuImageLoader(mContext, url).formatJpg().wR(R.dimen.hw_official_album_width).createQiniuUrl();
    }

    public static String getGalleryUrl(Context mContext, String url) {
        return new QiniuImageLoader(mContext, url).wR(R.dimen.hw_100_width).formatJpg().centerCrop().createQiniuUrl();
    }

    public static String getTimeCardUrl(String url, int width) {
        return url+"imageView2/2/w/"+width;
    }

    public static String getCoverUrl(Context mContext, String url) {
        return isKitkatUp() ? new QiniuImageLoader(mContext, url).wR(R.dimen.hw_cover_size).centerCrop().formatWebp().createQiniuUrl() : new QiniuImageLoader(mContext, url).wR(R.dimen.hw_cover_size).formatJpg().centerCrop().createQiniuUrl();
    }

    public static String getCoverUrl2(Context mContext, String url) {
        return new QiniuImageLoader(mContext, url).wR(R.dimen.hw_cover_size2).centerCrop().formatJpg().createQiniuUrl();
    }

}
